/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rdfparser.bean;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import rdfparser.db.DBConnection;

/**
 *
 * @author Amendra Shrestha
 */
public class UserBean {

    private String person;
    private String seeAlso;
    private String role;
    private String name;
    private String about;

    /**
     * @return the person
     */
    public String getPerson() {
        return person;
    }

    /**
     * @param person the person to set
     */
    public void setPerson(String person) {
        this.person = person;
    }

    /**
     * @return the seeAlso
     */
    public String getSeeAlso() {
        return seeAlso;
    }

    /**
     * @param seeAlso the seeAlso to set
     */
    public void setSeeAlso(String seeAlso) {
        this.seeAlso = seeAlso;
    }

    /**
     * @return the role
     */
    public String getRole() {
        return role;
    }

    /**
     * @param role the role to set
     */
    public void setRole(String role) {
        this.role = role;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the about
     */
    public String getAbout() {
        return about;
    }

    /**
     * @param about the about to set
     */
    public void setAbout(String about) {
        this.about = about;
    }

    public boolean addUser() {
        Connection con = null;
        PreparedStatement ps = null;
        
        try {
            con = DBConnection.getDBConnection();
            String tempPerson = getPerson();
            ps = con.prepareStatement("INSERT into tbl_user(User,Name,Role,BoardID) "
                    + "values(?,?,?,?)");
            ps.setString(1, tempPerson);
            ps.setString(2, getName());
            ps.setString(3, getRole());
            ps.setInt(4, Integer.parseInt(tempPerson.substring(tempPerson.indexOf('=') + 1,
                    tempPerson.indexOf('#'))));
            ps.executeUpdate();
            return true;
        } catch (SQLException ex) {
            return false;
        } finally {
            try {
                if (ps != null) {
                    ps.close();
                }
                if (con != null) {
                    con.close();
                }
            } catch (SQLException ex) {
            }
        }
    }
}
